package com.project.lx.gettxtfilename;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ListView;

import com.project.lx.gettxtfilename.widget.MyView;

import java.util.ArrayList;
import java.util.List;

/**
 * 页面
 */
public class DetailsActivity extends AppCompatActivity {

    Toolbar toolbar;
    ListView listView;
    View headImage;
    View headIntro;
    View headTime;

    MyView myView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_details);
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitle("");
        toolbar.setLogo(R.mipmap.ic_launcher);
        setSupportActionBar(toolbar);

        listView = (ListView) findViewById(R.id.list_detail);

        initHead();

        List list = new ArrayList();
        for (int i = 0; i < 3; i++){
            list.add(i);
        }

        DetailsAdapter detailsAdapter = new DetailsAdapter(this,list);
        listView.setAdapter(detailsAdapter);


        //设置预约时间
        List<int[]> timeList;
        timeList = new ArrayList<>();
        timeList.add(new int[]{10,16,1});
        timeList.add(new int[]{18,20,1});
        timeList.add(new int[]{12,22,2});
        timeList.add(new int[]{8,12,3});
        timeList.add(new int[]{14,20,3});

        myView.setTime(timeList);
    }

    public void initHead() {
        headImage = LayoutInflater.from(this).inflate(R.layout.details_content_head_image, null);
        headIntro = LayoutInflater.from(this).inflate(R.layout.details_content_head_introduce, null);
        headTime = LayoutInflater.from(this).inflate(R.layout.details_content_head_time, null);

        listView.addHeaderView(headImage);
        listView.addHeaderView(headIntro);
        listView.addHeaderView(headTime);
        myView = (MyView) headTime.findViewById(R.id.my_view);
    }
}
